package com.struts.utis;

import java.util.Map;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import com.struts.pojo.XmlVo;

public class ActionListener implements ServletContextListener {

	@Override
	public void contextDestroyed(ServletContextEvent arg0) {
		System.out.println("信息：系统已经注");
	}

	@Override
	public void contextInitialized(ServletContextEvent arg0) {
		ServletContext context = arg0.getServletContext();
		String xmlpath = context.getInitParameter("struts-config");
		String tomcatpath = context.getRealPath("\\");
		try {
			System.out.println(tomcatpath+xmlpath);
			Map<String, XmlVo> map = XmlLoadUtis.getBeanAttr(tomcatpath+xmlpath);
			context.setAttribute("struts", map);
		} catch(Exception e) {
			e.printStackTrace();
		}
		System.out.println("信息：系统已经加载完成！");
		
		
		String beanPath = context.getInitParameter("struts-service");
		String beanTomcatpath = context.getRealPath("\\");
		try {
			System.out.println(beanTomcatpath+beanPath+"+++++++++");
			XmlServiceLoadUtis.getBeanAttr(beanTomcatpath+beanPath);
		} catch (Exception e) {
			 System.out.println("调用service失败");
			e.printStackTrace();
		}
		
	}

}
